I cannot give you a diagnostic test to identify these to steels but I will comment that some of these posts are not exactly correct.
Here is some information about 4140:
The carbon content of this steel is 0.38 to 0.43 but has other alloying elements so it is an alloy steel.
4140 is a 1% chromium - molybdenum medium hardenability general purpose high tensile steel - generally supplied hardened and tempered in the tensile range of 860 - 1130 Mpa. Brinell hardness range 265 - 330 (Rc 28 - 36).
Characterised by high strength and good impact properties with good machinability, but low weldability.
Pre hardened and tempered 4140 can be further surface hardened by flame or induction hardening and by nitriding.
4140 is used extensively in most industry sectors for a wide range of applications utilising it's considerable savings on weight and machining time over solid bar.
Typical applications are: Bearings, Bushes, Cylinders (Various), Gears, Conveyor Rolls, Hydraulic Shafts, Hollow Shafts, Hollow Parts (Various), Nuts and Rings.
Heat Treatment
This alloy is hardened by heating to 1550 F and quenching in oil. It is best to normalize the alloy by heating at 1675 F for a long enough time to permit thorough heating, followed by air cooling, prior to the hardening treatment.
Here is some information on 1045:
This steel has a carbon content of 0.42 to 0.5 and it only has carbon and is a medium carbon steel.
1045 is a medium carbon steel is used when greater strength and hardness is desired than in the "as rolled" condition. Extreme size accuracy, straightness and concentricity combine to minimize wear in high speed applications. Turned, ground and polished bars can be machined unsymmetrically with minimum distortion.
Applications
Used in gears, shafts, axles, bolts, studs, and machine parts.
Heat Treatment
Suitable for flame and induction hardening.
In some posts it is mentioned that 1045 is Cold Rolled Steel. Normally when Cold Rolled Steel, CRS, is referred to what is meant is C1018 which is a low carbon steel with a carbon content of 0.15 t0 0.20
Here is some information on 1018:
Cold Rolled Type C1018 - A high quality, low carbon, smooth finished mild steel has good machining characteristics. It is easy to weld, braze and solder, making it a great material for models or prototypes.
This low carbon steel has good case hardening properties.
Although not classed as a screw machine steel at times it may be specified.
This is an excellent steel for bending and cold forming & is often used where cold forming stresses are not too severe.
C1018 has good brazing and welding properties.
It has a smooth - clean - cold drawn (rolled) surface.
Yield strengths are approx. 50000 PSI range & machine-ability is rated at 66% (c1212 = 100%) & 111 surface feet per minute.
Depending on the application it is possible the 1045 could work okay in place of 4140. It is likely that 1045 will machine better than 4140 but this does depend on whether it is annealed or hot rolled in an as-rolled condition.
An open mind is a virtue...so long as all the common sense has not leaked out.